﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class GameRules : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.GameRules_PageTitle;
            if (!Page.IsPostBack)
            {
                OnlineUser ou = (OnlineUser)Session["User"];
                GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();


                string TranslateLanguage = GND.ReadNivdalIntData("@UserId", "Nivdal_GetUserTranslateLanguage", ou.UserId);


                this.GamerulesDataSourse.SelectParameters.Add("LanguageCode", ou.Language);

                if (TranslateLanguage == ou.Language)
                    EditVisibleHiddenField.Value = "true";
                else
                    EditVisibleHiddenField.Value = "false";
            }

        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }

        protected bool EditVisible()
        {
            return (EditVisibleHiddenField.Value == "true");
        }

        protected string EncodeText(object str)
        {
            string ReturnValue = GlobalFunctions.LightEncodeHtmlFromText(str.ToString());
            ReturnValue = ReturnValue.Replace("[b]", "<b>").Replace("[/b]", "</b>").Replace("[i]", "<i>").Replace("[/i]", "</i>").Replace("[u]", "<u>").Replace("[/u]", "</u>");
            return ReturnValue;
        }

    }
}